<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
        html {
            font-size: 20px !important;
        }

        .aui-title {
            color: #303030 !important;
            font-size: 0.8rem !important;
        }

        .aui-pull-right {
            color: #2780e8 !important;
            font-size: 0.7rem !important;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav aui-bar-light hd"  id="app" v-cloak>
        <a id="back" class="aui-pull-left aui-btn">
            <img src="../image/icon_back.png" style="width: 0.45rem;height: 0.8rem;margin-left: 0.7rem;" alt="">
        </a>
        <div class="aui-title">
            添加药材
        </div>

        <a class="aui-pull-right aui-btn" onclick="save()">
            保存
        </a>
    </header>



</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready()
        hb_openframeby_auto('add_yaocai_frm', api.pageParam)

        if (api.pageParam.index == 1) {
            app.total_yaocai = api.pageParam.total_yaocai
        }

        //html页面a：
        api.addEventListener({
            name: 'total_yaocai'
        }, function (ret, err) {
            app.total_yaocai = ret.value.total_yaocai
        });
        //html页面a：
        api.addEventListener({
            name: 'queren_ok'
        }, function (ret, err) {
            app.total_quantity = 0
            for (var i = 0; i < app.total_yaocai.length; i++) {
                app.total_quantity += Number(app.total_yaocai[i].quantity)
            }
            api.sendEvent({
                name: 'save_yaocai',
                extra: {
                    total_yaocai: app.total_yaocai,
                }
            });
            toast("保存成功")
            setTimeout(function () {
                api.closeWin()
            }, 500);
            app.$nextTick(function () {
                hb_init_openwinby_click();
            })
        });
    };

    var app = new Vue({
        el: "#app",
        data: {
            total_yaocai: [],
            total_quantity: 0,
        }
    })

    function save() {
        // alert(JSON.stringify(app.total_yaocai))
        sendting("queren_yaocai")
    }
</script>

</html>